<template>
	<view class="container">
		<uni-list>
			<template v-for="(v,i) in mineList" :key="i">
				<uni-list-item showArrow :showExtraIcon="true" :extra-icon="{type:v.icon,size:'32'}"
					@click="goPage(v)" :title="v.title" clickable  >
				</uni-list-item>
			</template>
		</uni-list>
		<!-- 内容 -->
		
		<!-- 底部按钮 -->
		<view class="footer">
			<view :class="['btn',btnFlag?'checkBtn':'']">
				修改信息
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';
	import {
		upload
	} from "@/utils/upload.js"
	import {profile} from "@/api/user.js"
	// 控制底部
	const btnFlag = ref(false)
	// 头像
	const userImg = ref('/static/userheader.png')
	
	// 
	const mineList = reactive([{
		icon: 'images-filled',
		title: '头像',
		number: '',
		reditor: false,
		path: "/pagesD/contacts/contacts"
	}, 
	{
		icon: 'paperplane-filled',
		title: '昵称',
		number: '',
		reditor: false,
		path: ""
	}, 
	{
		icon: 'person-filled',
		title: '姓名',
		number: '188****1111',
		reditor: true,
		path: "/pagesC/mytel"
	}, {
		icon: 'staff-filled',
		title: '证件类型',
		number: '',
		reditor: false,
		path: "/pagesD/customer/customer"
	},
	{
		icon: 'locked-filled',
		title: '证件号码',
		number: '',
		reditor: false,
		path: "/pagesD/customer/customer"
	},
	{
		icon: 'scan',
		title: '会员码',
		number: '',
		reditor: false,
		path: "/pagesD/customer/customer"
	}])
	
	function goPage(item){
		if(item.title==="头像"){
			headerUpload()
		}
	}
	
	function headerUpload(){
		uni.chooseImage({
			success: (chooseImageRes) => {
				const tempFilePaths = chooseImageRes.tempFilePaths;
				upload(tempFilePaths[0]).then(e => {
					console.log(e.code)
					saveUsers({headerurl:e.data.fullurl})
				})
			}
		})
	}
	
	function saveUsers(data){
		console.log(data,99)
		profile(data).then(e=>{
			console.log(e,99)
		})
	}
</script>

<style lang="less" scoped>
	.container {
		display: flex;
		flex-direction: column;
		.footer {
			width: 100%;
			padding: 20rpx 40rpx;
			box-sizing: border-box;

			.btn {
				color: #fff;
				width: 100%;
				border-radius: 100rpx;
				line-height: 100rpx;
				text-align: center;
				background: #c5c3c3;
				font-size: 40rpx;
			}

			.checkBtn {
				background: orangered;
			}
		}
	}
</style>